package test2;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Test1 {
    public static void main(String[] args)throws Exception {


//        Connection connection = DBUtils.getConnection();
//        String sql="update t_student set name=?,age=? where id=?";
//        PreparedStatement ps = connection.prepareStatement(sql);
//        ps.setString(1,"zss");
//        ps.setString(2,"33");
//
//        ps.setString(3,"A0003");
//        ps.executeUpdate();
//        DBUtils.close(connection,ps);



//        Connection connection = DBUtils.getConnection();
//        String sql="delete  from t_student where id=?";
//        PreparedStatement ps = connection.prepareStatement(sql);
//        ps.setString(1,"A0003");
//        ps.executeUpdate();
//        DBUtils.close(connection,ps);


        Connection connection = DBUtils.getConnection();
        String sql="select * from t_student where name like ?";
        PreparedStatement ps = connection.prepareStatement(sql);

        ps.setString(1,"%l%");
        ResultSet resultSet = ps.executeQuery();

        while (resultSet.next())
        {
            String id=resultSet.getString("id");
            String string = resultSet.getString("name");
            int age = resultSet.getInt("age");
            System.out.println(id);
            System.out.println(string);
            System.out.println(age);
            System.out.println("----------------");
        }
        DBUtils.close(connection,ps);
    }

}
